package com.jnuo.mdb;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

/**
 * Created by zhangyuncai on 2019/4/11.
 * 解决精度问题
 */
class MdbNumUtil {

    private static DecimalFormat twolastDF = new DecimalFormat("#0.00");
    private static DecimalFormat onelastDF = new DecimalFormat("#0.0");
    private static DecimalFormat IntlastDF = new DecimalFormat("#0");

    static {
        DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
        decimalFormatSymbols.setDecimalSeparator('.');
        onelastDF.setDecimalFormatSymbols(decimalFormatSymbols);
        twolastDF.setDecimalFormatSymbols(decimalFormatSymbols);
        IntlastDF.setDecimalFormatSymbols(decimalFormatSymbols);
    }

    public static DecimalFormat getInstant() {
        DecimalFormat df = new DecimalFormat();
        DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
        decimalFormatSymbols.setDecimalSeparator('.');
        df.setDecimalFormatSymbols(decimalFormatSymbols);
        return df;
    }

    public static DecimalFormat getInstant(String pattern) {
        DecimalFormat df = new DecimalFormat(pattern);
        DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
        decimalFormatSymbols.setDecimalSeparator('.');
        df.setDecimalFormatSymbols(decimalFormatSymbols);
        return df;
    }


}
